package com.fpt.mockproject.j21.absd.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NaturalId;

@Entity
@Table(name = "REFERENCE_DATA")
@DynamicUpdate(value = true)
public class ReferenceData {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "RefID", nullable = false, updatable = false, unique = true)
	private Long refID;
	
	@NaturalId
	@Column(name = "RefCode", nullable = false, unique = true)
	private String refCode;
	
	@Column(name = "RefName", nullable = false)
	private String refName;
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "ServiceGroupID")
	private ServiceGroup serviceGroup;
	
	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "referDatas")
	private Set<Organisation> organisations = new HashSet<>(0);
	
	public Set<Organisation> getOrganisations() {
		return organisations;
	}
	public void setOrganisations(Set<Organisation> organisations) {
		this.organisations = organisations;
	}
	public ServiceGroup getServiceGroup() {
		return serviceGroup;
	}
	public void setServiceGroup(ServiceGroup serviceGroup) {
		this.serviceGroup = serviceGroup;
	}
	public Long getRefID() {
		return refID;
	}
	public void setRefID(Long refID) {
		this.refID = refID;
	}
	public String getRefCode() {
		return refCode;
	}
	public void setRefCode(String refCode) {
		this.refCode = refCode;
	}
	public String getRefName() {
		return refName;
	}
	public void setRefName(String refName) {
		this.refName = refName;
	}
}
